﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace EasyPiano
{
    public partial class SoundNumberControl : UserControl
    {
        string text = "0";
        int theme = 0;
        public SoundNumberControl()
        {
            InitializeComponent();            
        }
        public void SetTheme(int theme)
        {
            this.theme = theme;
            if (theme == 0)
            {
                lb_num.ForeColor = Color.Black;
            }
            else
            {
                lb_num.ForeColor = Color.White;
            }
            SetLable(this.text);
        }
        public string NumberText
        {
            set
            {
                text = value;
                SetLable(value);
            }
            get
            {
                return text;
            }
        }
        public override string Text
        {
            set
            {
                lb_num.Text = value;
                lb_num.Image = null;
            }
            get
            {
                return lb_num.Text;
            }
        }

        void SetLable(string text)
        {
            lb_num.Text = Util.GetSoundStringNumber(text);
            int rank = Util.GetSoundStringRank(text);
            if(theme==0)
            {
                switch (rank)
                {
                    case 0:
                        lb_num.Image = null;
                        break;
                    case 1:
                        lb_num.Image = global::EasyPiano.Properties.Resources.h_1;
                        break;
                    case 2:
                        lb_num.Image = global::EasyPiano.Properties.Resources.h_2;
                        break;
                    case 3:
                        lb_num.Image = global::EasyPiano.Properties.Resources.h_3;
                        break;
                    case 4:
                        lb_num.Image = global::EasyPiano.Properties.Resources.h_4;
                        break;
                    case -1:
                        lb_num.Image = global::EasyPiano.Properties.Resources.l_1;
                        break;
                    case -2:
                        lb_num.Image = global::EasyPiano.Properties.Resources.l_2;
                        break;
                    case -3:
                        lb_num.Image = global::EasyPiano.Properties.Resources.l_3;
                        break;
                    case -4:
                        lb_num.Image = global::EasyPiano.Properties.Resources.l_4;
                        break;
                }
            }
            else
            {
                switch (rank)
                {
                    case 0:
                        lb_num.Image = null;
                        break;
                    case 1:
                        lb_num.Image = global::EasyPiano.Properties.Resources.h_11;
                        break;
                    case 2:
                        lb_num.Image = global::EasyPiano.Properties.Resources.h_21;
                        break;
                    case 3:
                        lb_num.Image = global::EasyPiano.Properties.Resources.h_31;
                        break;
                    case 4:
                        lb_num.Image = global::EasyPiano.Properties.Resources.h_41;
                        break;
                    case -1:
                        lb_num.Image = global::EasyPiano.Properties.Resources.l_11;
                        break;
                    case -2:
                        lb_num.Image = global::EasyPiano.Properties.Resources.l_21;
                        break;
                    case -3:
                        lb_num.Image = global::EasyPiano.Properties.Resources.l_31;
                        break;
                    case -4:
                        lb_num.Image = global::EasyPiano.Properties.Resources.l_41;
                        break;
                }
            }
        }

        private void lb_num_MouseDown(object sender, MouseEventArgs e)
        {
            base.OnMouseDown(e);
        }

        private void lb_num_MouseUp(object sender, MouseEventArgs e)
        {
            base.OnMouseUp(e);
        }

        private void lb_num_Click(object sender, EventArgs e)
        {
            base.OnClick(e);
        }
    }
}
